#include <bits/stdc++.h>
using namespace std;
map<char,int> mp;
int main()
{
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  string arr;
  cin>>arr;
  int len=arr.length();
  for(int i=0;i<len;++i)
  {
    mp[arr[i]]++;
    
  }
  int maxvalue=0;
  char maxkey;
  for(auto&a:mp)
  {
    if(a.second>maxvalue)
    {
      maxvalue=a.second;
      maxkey=a.first;
    }
    else if(a.second==maxvalue&&a.first<maxkey)
    {
      maxkey=a.first;
    }
  }
  cout<<maxkey<<endl<<maxvalue<<endl;
  return 0;
}
